package org.example.library.Dao;

import org.example.library.entity.BookInfo;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

@Component
public class BookDao {
    //模拟数据库返回的数据
    public List<BookInfo> mockBookData(){
        List<BookInfo> bookInfos =new ArrayList<>();
        for (int i=1;i<=8;i++){
            BookInfo bookInfo=new BookInfo();
            bookInfo.setId(i);
            bookInfo.setBookName("Spring Boot"+i);
            bookInfo.setAuthor("小马哥"+i);
            bookInfo.setCount(i*5+i);
            bookInfo.setPrice(new BigDecimal(new Random().nextInt(100)));
            bookInfo.setPublish("小马哥出版社"+i);
            bookInfo.setStatus(i%5==0?2:1);
            bookInfos.add(bookInfo);
        }
        return bookInfos;
    }
}
